package com.mspbots.cw.amqp.receivers;

import com.mspbots.cw.amqp.BaseReceiver;
import com.mspbots.cw.amqp.model.CallbackHistory;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * CallbackHistoryReceiver is com.mspbots.cw.amqp.receivers
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/2/6
 */
@Log4j2
@Component
@RequiredArgsConstructor
public class CallbackHistoryReceiver extends BaseReceiver {

    @RabbitListener(queues = "callback.history")
    public void processMessage(CallbackHistory content) {
        log.debug("callback.history receiver is {}", content);
        this.databaseClient.insert().into(CallbackHistory.class)
                .using(content).fetch().rowsUpdated().block();
    }

}
